package com.edu.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.edu.bean.CommonResult;
import com.edu.bean.User;
import com.edu.service.UserService;
import com.edu.service.impl.UserServiceImpl;
@WebServlet("/selectuserid.do")
public class SelectUseridServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		UserService us =new UserServiceImpl();
		String id =req.getParameter("userid");
		int userid = Integer.parseInt(id);
		User user =us.getUserById(userid);
		CommonResult result = new CommonResult();
		result.setCode(200);
		result.setMessage("success");
		result.setData(user);
		resp.setContentType("application/json;charset=utf-8");
		resp.getWriter().write(result.toJsonString());
	}
}
